package com.wealth.member.web.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wealth.order.entity.Order;
import com.wealth.order.service.IOrderService;
import com.wealth.order.vo.OrderVOCenter;
import com.wealth.system.web.controller.BaseController;

import iaas.utils.ResultObject;


/**
 * 消费记录
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/manage/consumption")
public class ConsumptionController extends BaseController{

	Logger logger = Logger.getLogger(ConsumptionController.class);
	@Autowired
	private IOrderService orderService;
	
	//消费记录
	@RequestMapping(value="/index")
	public String evaluateForm(Model model){
		try {
			int count = orderService.countPayStatusOrder(memberid);
			model.addAttribute("count", count);
			return "order/consumption";
		} catch (Exception e) {
			logger.error("消费记录", e);
			return "system/500";
		}
	}
		
	//加载更多订单
	@RequestMapping(value="/more",method=RequestMethod.POST)
	@ResponseBody
	public ResultObject list(
			@RequestParam(defaultValue="1") Integer status,
			@RequestParam(defaultValue="-1") Integer index,
			@RequestParam(defaultValue="10") Integer offset) {
		try{
			List<OrderVOCenter> orderList = orderService.ajaxConsumption(memberid, status, index, offset);
			return new ResultObject("000", "加载成功", orderList);
		}catch(Exception e){
			return new ResultObject("999", "加载错误", "");
		}
	}
	
	
	
}
